<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<TITLE>JpGraph Manual (ver:30 Oct 2002 09:48)</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-8859-1">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<IMG  src="img/JpGraph_Logo.png">
<A HREF="index.html">Contents</A>
<A HREF="3060combplots.html">Previous</A>
<A HREF="3080graphaug.html">Next</A>
<HR>
<H2><A NAME="6_7">6.7 Specifying the scale manually</A></H2>
 Normally the automatic scaling should be doing an adequate job in most
 circumstances but there might be cases where you like to manually set
 the scale. For example if you have several graphs where you like to be
 able to easlily compare them and therefore want them all to have the
 same scale.
<P> To specify a manual scale you have to add arguments to the standard<A
href="../ref/Graph.html#_GRAPH_SETSCALE"> Graph::SetScale()</A> method.
 So to specify that you want an Y-scale between 0 and 100 you need to
 write
<BR> &nbsp;
<BR><DIV style="background-color:#E6E6E6;font-family:courier new;font-size:85%;font-weight:bold;">
<B><CODE><FONT color="#000000"><FONT color="#0000CC"> $graph</FONT><FONT color="#006600">
-&gt;</FONT><FONT color="#0000CC">SetScale</FONT><FONT color="#006600">(</FONT><FONT
color="#CC0000">&quot;textlin&quot;</FONT><FONT color="#006600">,</FONT><FONT color="#0000CC">
0</FONT><FONT color="#006600">,</FONT><FONT color="#0000CC">100</FONT><FONT
color="#006600">);</FONT><FONT color="#0000CC"></FONT></FONT></CODE></B></DIV>
</P>
<P> When you specify a scale manually there is one additional thing you
 need to decide. How the tick marks should be positioned. You have two
 choices</P>
<OL>
<LI> Manually specify the tick marks with a call to<A href="../ref/LinearTicks.html#_LINEARTICKS_SET">
 LinearTicks::Set()</A> This is the default behavious. Hence every
 manually specified scale must be followed by a call that sets the tick
 marks. For example
<BR> &nbsp;
<BR><DIV style="background-color:#E6E6E6;font-family:courier new;font-size:85%;font-weight:bold;">
<B><CODE><FONT color="#000000"><FONT color="#0000CC"> $graph</FONT><FONT color="#006600">
-&gt;</FONT><FONT color="#0000CC">SetScale</FONT><FONT color="#006600">(</FONT><FONT
color="#CC0000">&quot;textlin&quot;</FONT><FONT color="#006600">,</FONT><FONT color="#0000CC">
0</FONT><FONT color="#006600">,</FONT><FONT color="#0000CC">100</FONT><FONT
color="#006600">);
<BR /></FONT><FONT color="#0000CC">$graph</FONT><FONT color="#006600">-&gt;</FONT><FONT
color="#0000CC">yscale</FONT><FONT color="#006600">-&gt;</FONT><FONT color="#0000CC">
ticks</FONT><FONT color="#006600">-&gt;</FONT><FONT color="#0000CC">Set</FONT><FONT
color="#006600">(</FONT><FONT color="#0000CC">10</FONT><FONT color="#006600">
,</FONT><FONT color="#0000CC">5</FONT><FONT color="#006600">);</FONT><FONT
color="#0000CC"></FONT></FONT></CODE></B></DIV></LI>
<P> Will set the major tick marks every at 0,10,20,.. And every minor
 tick mark in between (0,5,10,15,20,25,...).</P>
<LI> Let JpGraph decide the best tick marks. You have to tell JpGraph
 that you want the tick marks to be set automatically by calling<A href="../ref/LinearScale.html#_LINEARSCALE_SETAUTOTICKS">
 LinearScale::SetAutoTicks()</A> What you need to be aware of here is
 that this might slightly chance the min and max values you have
 specified. This is done so that the scale will start and end on a major
 tick mark.</LI>
</OL>
 The two images below illustrates this. They both have a manual scale,
 the left a manual ticks and the right automatic ticks.
<TABLE border="0">
<TR><TD valign="top">
<P><DIV align="center">
<BR><A href="exframes/frame_manscaleex1.html"> <IMG border="0" HEIGHT="200"
 src="img/manscaleex1.png" WIDTH="250"></A>
<BR><SMALL><EM><B>Figure 1:</B> Manual scale, manual ticks<A href="exframes/frame_manscaleex1.html">
 [src]</A></EM></SMALL></DIV></P>
<P></P>
</TD><TD valign="top">
<P><DIV align="center">
<BR><A href="exframes/frame_manscaleex2.html"> <IMG border="0" HEIGHT="200"
 src="img/manscaleex2.png" WIDTH="250"></A>
<BR><SMALL><EM><B>Figure 2:</B> Manual scale, automatic ticks using
 SetAutoTicks()<A href="exframes/frame_manscaleex2.html"> [src]</A></EM></SMALL>
</DIV></P>
<P></P>
</TD></TR>
</TABLE>
<H2><A NAME="6_8">6.8 Adjsuting the automatic tick marks</A></H2>
 You can adjust the automtic tick marks by telling JpGraph how dense you
 want them to be. You use the<A href="../ref/Graph.html#_GRAPH_SETTICKDENSITY">
 Graph::SetTickDensity()</A> method. You can set the density setting in
 four steps
<UL>
<LI> TICKD_VERYSPARSE, Very few ticks</LI>
<LI> TICKD_SPARSE, Few ticks</LI>
<LI> TICKD_NORMAL, Standard number of ticks</LI>
<LI> TICKD_DENSE, Large number of ticks</LI>
</UL>
 Taking the previous example with the manual scale but automatic ticks
 and using a denser ticks setting gives the following result
<P><DIV align="center">
<BR><A href="exframes/frame_manscaleex3.html"> <IMG border="0" HEIGHT="200"
 src="img/manscaleex3.png" WIDTH="250"></A>
<BR><SMALL><EM><B>Figure 3:</B> Manual scale with automatic ticks but
 with a denser tick settings.<A href="exframes/frame_manscaleex3.html">
 [src]</A></EM></SMALL></DIV></P>
<P></P>
<H2><A NAME="6_9">6.9 Adjusting labels on a text scale</A></H2>
 In the following section we will work through an number of examples on
 how to manipulate labels on a text scale. Primarily we will investigate
 how to best handle the case where you have a large number of values.
<P> As a remainder; Text scale is meant to be used on the X-axis when
 the X-axis doesn't have a numeric value, i.e you are only ineterested
 in linear ordering of the data. If you don't specify the labels
 manually they will be set automtically starting from 1 as the example
 below shows.</P>
<P></P>
<P><DIV align="center">
<BR><A href="exframes/frame_bartutex1.html"> <IMG border="0" HEIGHT="200"
 src="img/bartutex1.png" WIDTH="300"></A>
<BR><SMALL><EM><B>Figure 4:</B> A simple bar plot using an automatic
 text scale<A href="exframes/frame_bartutex1.html"> [src]</A></EM></SMALL>
</DIV></P>
<P></P>
<P> To specify the labels on the X-axis as suitable text strings you
 call the method<A href="../ref/Axis.html#_AXIS_SETTICKLABELS">
 Axis::SetTickLabels()</A> with an array containing the text-labels. If
 there are more data points than labels the non-specified labels will be
 gioven their ordinal number. If we augument the previous example with
 the name of the month we get the following new example</P>
<P></P>
<P><DIV align="center">
<BR><A href="exframes/frame_bartutex2.html"> <IMG border="0" HEIGHT="200"
 src="img/bartutex2.png" WIDTH="300"></A>
<BR><SMALL><EM><B>Figure 5:</B> Manually specifying the text scale
 labels<A href="exframes/frame_bartutex2.html"> [src]</A></EM></SMALL></DIV>
</P>
<P></P>
<P></P>
<HR> <SMALL><STRONG> Tip:</STRONG> To get hold of localized version of
 the month names (or weekdays) you can use the<A href="../ref/DateLocale.html#_C_DATELOCALE">
 DateLocal</A> class available in the global variable $gDateLocale If no
 locale has been specified the default locale for the installation will
 be used.</SMALL>
<HR>
<P> What happen now if we have a larger number of bars? Let's try with
 25 bars and see what result we get.</P>
<P></P>
<P><DIV align="center">
<BR><A href="exframes/frame_bartutex3.html"> <IMG border="0" HEIGHT="200"
 src="img/bartutex3.png" WIDTH="300"></A>
<BR><SMALL><EM><B>Figure 6:</B> A larger data set<A href="exframes/frame_bartutex3.html">
 [src]</A></EM></SMALL></DIV></P>
<P></P>
<P> Not all to impressive. The labels are to close and they overlap.
 Hence it is not a good idea to sisplay every label. To adjust what
 labels are to be displayed you use the<A href="../ref/Axis.html#_AXIS_SETTEXTLABELINTERVAL">
 SetTextLabelInterval()</A> method. The argument to this method is the
 itervall between text labels. So to display only every 3 month you
 would add the line</P>
<P></P>
<P> Which would give the result shown below</P>
<P><DIV align="center">
<BR><A href="exframes/frame_bartutex4.html"> <IMG border="0" HEIGHT="200"
 src="img/bartutex4.png" WIDTH="300"></A>
<BR><SMALL><EM><B>Figure 7:</B> Displaying only every third label<A href="exframes/frame_bartutex4.html">
 [src]</A></EM></SMALL></DIV></P>
<P></P>
<P> Much better, quite readable.</P>
<P> If we have an even larger data setit might not longer be meaningfull
 to display all the tick marks since they would simple become to close.
 In JpGraph there is a possibility to specify that you only would like
 every<I> n</I>:th tick mark to be visible (<A href="../ref/Axis.html#_AXIS_SETTEXTTICKINTERVAL">
 SetTextTickIntervall()</A> ). For bar graphs using text scale however,
 that might not be such a good idea since the tick marks are between the
 bars and the labels centered under the bars. If we only were to disply,
 say, every 3 tick mark it wouldn't look to good. Not that we can't do
 it, as the example below shows, but it just doesn't look very good.</P>
<P><DIV align="center">
<BR><A href="exframes/frame_bartutex5.html"> <IMG border="0" HEIGHT="200"
 src="img/bartutex5.png" WIDTH="300"></A>
<BR><SMALL><EM><B>Figure 8:</B> Displaying just every third tick mark.<A href="exframes/frame_bartutex5.html">
 [src]</A></EM></SMALL></DIV></P>
<P></P>
<P> A better way to handle large data set is simply to hide the tick
 marks all together. Tick marks may be hidden by calling the method<A href="../ref/Axis.html#_AXIS_HIDETICKS">
 Axis::HideTicks();<A> If we hide all the ticks on the X-axis we will
 get the result shown below</A></A></P>
<P><DIV align="center">
<BR><A href="exframes/frame_bartutex6.html"> <IMG border="0" HEIGHT="200"
 src="img/bartutex6.png" WIDTH="300"></A>
<BR><SMALL><EM><B>Figure 9:</B> Hiding all tick mark.<A href="exframes/frame_bartutex6.html">
 [src]</A></EM></SMALL></DIV></P>
<P> More ... [ TBC ]</P>
<HR>
<IMG  src="img/JpGraph_Logo.png">
<A HREF="index.html">Contents</A>
<A HREF="3060combplots.html">Previous</A>
<A HREF="3080graphaug.html">Next</A>
</BODY>
</HTML>
